{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 0
   },
   "source": [
    "# Packed Convolution\n",
    ":label:`ch_packed_conv_cpu`\n",
    "\n",
    "We observed in :numref:`ch_conv_cpu` that the performance degrades when increasing the channel size for the convolution operator. In this section, we will consider tiling the channel axes and packing the data to improve the performance.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "attributes": {
     "classes": [],
     "id": "",
     "n": "11"
    },
    "origin_pos": 1,
    "tab": [
     "tvm"
    ]
   },
   "outputs": [],
   "source": [
    "import d2ltvm\n",
    "import numpy as np\n",
    "import tvm\n",
    "from tvm import te\n",
    "import os\n",
    "\n",
    "os.environ['KMP_AFFINITY']='granularity=fine,noduplicates,compact,1,0'\n",
    "target = 'llvm -mcpu=skylake-avx512'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 2
   },
   "source": [
    "## Packing Data and Weight\n",
    "\n",
    "In :numref:`ch_conv_cpu`, we first tiled the width and height axes and then moved the inner axes as the innermost dimensions during computing. It's the same idea to tile the channels. But we do one additional step to actually move the data in the inner channel loop to the last dimension, i.e. do data layout transformation. So we pay the data movement cost once, while improving the data accessing performance significantly.\n",
    "\n",
    "The following code block splits the channel dimension and move the data in NumPy.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "attributes": {
     "classes": [],
     "id": "",
     "n": "12"
    },
    "origin_pos": 3,
    "tab": [
     "tvm"
    ]
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "input shape (4, 2, 2) \n",
      " [[[ 0.  1.]\n",
      "  [ 2.  3.]]\n",
      "\n",
      " [[ 4.  5.]\n",
      "  [ 6.  7.]]\n",
      "\n",
      " [[ 8.  9.]\n",
      "  [10. 11.]]\n",
      "\n",
      " [[12. 13.]\n",
      "  [14. 15.]]]\n",
      "packed shape (2, 2, 2, 2) \n",
      " [[[[ 0.  4.]\n",
      "   [ 1.  5.]]\n",
      "\n",
      "  [[ 2.  6.]\n",
      "   [ 3.  7.]]]\n",
      "\n",
      "\n",
      " [[[ 8. 12.]\n",
      "   [ 9. 13.]]\n",
      "\n",
      "  [[10. 14.]\n",
      "   [11. 15.]]]]\n"
     ]
    }
   ],
   "source": [
    "c, n, tc = 4, 2, 2  # channel, height/width, and tiling size\n",
    "x = np.arange(c*n*n).reshape((c, n, n)).astype('float32')\n",
    "print('input shape', x.shape, '\\n', x)\n",
    "y = x.reshape(c//tc, n, n, tc).transpose(0, 2, 3, 1)\n",
    "print('packed shape', y.shape, '\\n', y)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 4
   },
   "source": [
    "Now let's implement the pack computation in TVM.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "attributes": {
     "classes": [],
     "id": "",
     "n": "13"
    },
    "origin_pos": 5,
    "tab": [
     "tvm"
    ]
   },
   "outputs": [],
   "source": [
    "def conv_pack(oc, ic, nh, nw, kh, kw, ph, pw, toc, tic):\n",
    "    \"\"\"Pack data and weight for convolution\n",
    "\n",
    "    oc, ic : output and input channels\n",
    "    nh, nw : input width and height\n",
    "    kh, kw : kernel width and height\n",
    "    ph, pw : height and width padding\n",
    "    toc, tic : the tiling sizes of the output and input channels\n",
    "    \"\"\"\n",
    "    X = te.placeholder((ic, nh, nw), name='X')\n",
    "    K = te.placeholder((oc, ic, kh, kw), name='K')\n",
    "    PaddedX = d2ltvm.padding(X, ph, pw) if ph * pw != 0 else X\n",
    "    # pack X and K\n",
    "    assert ic % tic == 0 and oc % toc == 0\n",
    "    PackedX = te.compute(\n",
    "        (ic//tic, nh+ph*2, nw+pw*2, tic),\n",
    "        lambda ic_out, x, y, ic_in: PaddedX[ic_out*tic + ic_in, x, y],\n",
    "        name='PackedX')\n",
    "    PackedK = te.compute(\n",
    "        (oc//toc, ic//tic, kh, kw, tic, toc),\n",
    "        lambda oc_out, ic_out, x, y, ic_in, oc_in: K[\n",
    "            oc_out*toc + oc_in, ic_out*tic + ic_in, x, y],\n",
    "        name='PackedK')\n",
    "    return X, K, PaddedX, PackedX, PackedK"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 6
   },
   "source": [
    "Verify the results by re-implementing the previous example.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "attributes": {
     "classes": [],
     "id": "",
     "n": "14"
    },
    "origin_pos": 7,
    "tab": [
     "tvm"
    ]
   },
   "outputs": [],
   "source": [
    "X, _, _, PackedX, _ = conv_pack(c, c, n, n, 1, 1, 0, 0, tc, tc)\n",
    "mod = tvm.build(te.create_schedule(PackedX.op), [X, PackedX])\n",
    "packed_x = tvm.nd.array(np.empty((c//tc, n, n, tc), dtype='float32'))\n",
    "mod(tvm.nd.array(x), packed_x)\n",
    "np.testing.assert_equal(packed_x.asnumpy(), y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 8
   },
   "source": [
    "Of note, in :numref:`ch_conv` we defined the layout of the input data to be `NCHW`. For the packed data `PackedX` here, we follow the convention defined in :cite:`Liu.Wang.Yu.ea.2019` to define its layout as `NCHW[x]c`, where `x` describes the size of `c`, which is 2 (the value of `tc` above) in this case.\n",
    "\n",
    "## Computation\n",
    "\n",
    "Since we changed the data layout, we need to re-implement the convolution computation accordingly.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "attributes": {
     "classes": [],
     "id": "",
     "n": "15"
    },
    "origin_pos": 9,
    "tab": [
     "tvm"
    ]
   },
   "outputs": [],
   "source": [
    "def conv(oc, ic, nh, nw, kh, kw, ph, pw, sh, sw, toc, tic):\n",
    "    \"\"\"2-D conv\n",
    "\n",
    "    oc, ic : output and input channels.\n",
    "    nh, nw : input width and height\n",
    "    kh, kw : kernel width and height\n",
    "    ph, pw : height and width padding\n",
    "    sh, sw : height and width strides\n",
    "    toc, tic : the tiling sizes of output channel and input channel\n",
    "    \"\"\"\n",
    "    X, K, PaddedX, PackedX, PackedK = conv_pack(\n",
    "        oc, ic, nh, nw, kh, kw, ph, pw, toc, tic)\n",
    "    # reduction axes\n",
    "    ric_in = te.reduce_axis((0, tic), name='ric_in')\n",
    "    ric_out = te.reduce_axis((0, ic//tic), name='ric_out')\n",
    "    rkh = te.reduce_axis((0, kh), name='rkh')\n",
    "    rkw = te.reduce_axis((0, kw), name='rkw')\n",
    "    # output height and weights\n",
    "    oh = d2ltvm.conv_out_size(nh, kh, ph, sh)\n",
    "    ow = d2ltvm.conv_out_size(nw, kw, pw, sw)\n",
    "    # Compuated Y in the packed layout\n",
    "    PackedY = te.compute(\n",
    "        (oc//toc, oh, ow, toc),\n",
    "        lambda oc_out, x, y, oc_in: te.sum(\n",
    "            PackedX[ric_out, x*sh+rkh, y*sw+rkw, ric_in] *\n",
    "            PackedK[oc_out, ric_out, rkh, rkw, ric_in, oc_in],\n",
    "            axis=[ric_out, rkh, rkw, ric_in]), name='Y')\n",
    "    # Unpack the result\n",
    "    Y = te.compute((oc, oh, ow),\n",
    "                    lambda oc, x, y: PackedY[oc//toc, x, y, oc%toc],\n",
    "                    name='Y')\n",
    "    return X, K, Y, PaddedX, PackedX, PackedK, PackedY"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 10
   },
   "source": [
    "Let's compile it using the default scheduling and compute the results.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "attributes": {
     "classes": [],
     "id": "",
     "n": "16"
    },
    "origin_pos": 11,
    "tab": [
     "tvm"
    ]
   },
   "outputs": [],
   "source": [
    "oc, ic, n, k, p, s, toc, tic = 4, 6, 12, 3, 1, 1, 2, 3\n",
    "X, K, Y, _, _, _, _ = conv(oc, ic, n, n, k, k, p, p, s, s, toc, tic)\n",
    "mod = tvm.build(te.create_schedule(Y.op), [X, K, Y])\n",
    "\n",
    "data, weight, out = d2ltvm.get_conv_data(oc, ic, n, k, p, s, tvm.nd.array)\n",
    "mod(data, weight, out)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 12
   },
   "source": [
    "And then verify the result.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "attributes": {
     "classes": [],
     "id": "",
     "n": "17"
    },
    "origin_pos": 13,
    "tab": [
     "tvm"
    ]
   },
   "outputs": [],
   "source": [
    "data, weight, bias, out_mx = d2ltvm.get_conv_data_mxnet(oc, ic, n, k, p, s)\n",
    "d2ltvm.conv_mxnet(data, weight, bias, out_mx, k, p, s)\n",
    "np.testing.assert_allclose(out_mx[0].asnumpy(), out.asnumpy(), atol=1e-5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 14
   },
   "source": [
    "## Schedule\n",
    "\n",
    "The optimization strategy here is similar to :numref:`ch_conv_cpu`. The major differences are\n",
    "\n",
    "1. the innermost axis is the inner axis split from the output channel because the elements have already sit on the last dimension after packing.\n",
    "2. We only split the width dimension instead of both width and height dimensions.\n",
    "3. We need to schedule the packing and unpacking computations as well.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "attributes": {
     "classes": [],
     "id": "",
     "n": "18"
    },
    "origin_pos": 15,
    "tab": [
     "tvm"
    ]
   },
   "outputs": [],
   "source": [
    "# tiling sizes for output channel, input channel, and width\n",
    "toc, tic, tw = 16, 16, 4\n",
    "\n",
    "def cached_block(oc, ic, n, k, p, s):\n",
    "    X, K, Y, PaddedX, PackedX, PackedK, PackedY = conv(\n",
    "        oc, ic, n, n, k, k, p, p, s, s, toc, tic)\n",
    "    s = te.create_schedule(Y.op)\n",
    "    CachedY = s.cache_write(PackedY, 'local')\n",
    "    oc_out, h, w, oc_in = s[PackedY].op.axis\n",
    "    oc_out_h = s[PackedY].fuse(oc_out, h)\n",
    "    # Parallel on the first two dimensions oc_out and h\n",
    "    s[PackedY].parallel(oc_out_h)\n",
    "    # Optimize the computation of a cached output block\n",
    "    w_out, w_in = s[PackedY].split(w, factor=tw)  # Split the columns\n",
    "    s[CachedY].compute_at(s[PackedY], w_out)\n",
    "    _, _, cw, oc_in = CachedY.op.axis\n",
    "    ric_out, rkh, rkw, ric_in = CachedY.op.reduce_axis\n",
    "    s[CachedY].reorder(ric_out, rkh, rkw, ric_in, cw, oc_in)\n",
    "    s[CachedY].unroll(ric_in)\n",
    "    s[CachedY].unroll(cw)\n",
    "    s[CachedY].vectorize(oc_in)\n",
    "    # Schedule the padding by adding thread-level parallelism\n",
    "    if PaddedX != X:\n",
    "        s[PaddedX].parallel(PaddedX.op.axis[0])\n",
    "    # Optimize the packing of X and K\n",
    "    s[PackedX].parallel(s[PackedX].fuse(*PackedX.op.axis[0:2]))\n",
    "    s[PackedX].unroll(PackedX.op.axis[-1])\n",
    "    s[PackedK].parallel(s[PackedK].fuse(*PackedK.op.axis[0:2]))\n",
    "    s[PackedK].unroll(PackedK.op.axis[-1])\n",
    "    # Optimize the unpacking of Y\n",
    "    s[Y].parallel(s[Y].fuse(*Y.op.axis[0:2]))\n",
    "    s[Y].unroll(Y.op.axis[-1])\n",
    "    return s, (X, K, Y)\n",
    "\n",
    "s, args = cached_block(32, 32, 64, 3, 1, 1)\n",
    "# Uncomment the following line to see the long\n",
    "# psuedo codes because of unrolling.\n",
    "# tvm.lower(s, args, simple_mode=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 16
   },
   "source": [
    "Let's benchmark then same workloads as :numref:`ch_conv_cpu` and compare to our MXNet baseline. As you can see, the results are significantly improved.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "attributes": {
     "classes": [],
     "id": "",
     "n": "19"
    },
    "origin_pos": 17,
    "tab": [
     "tvm"
    ]
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Created with matplotlib (https://matplotlib.org/) -->\n",
       "<svg height=\"209.656811pt\" version=\"1.1\" viewBox=\"0 0 320.778125 209.656811\" width=\"320.778125pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2020-10-13T10:44:17.688055</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.3.2, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linecap:butt;stroke-linejoin:round;}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 209.656811 \n",
       "L 320.778125 209.656811 \n",
       "L 320.778125 0 \n",
       "L 0 0 \n",
       "z\n",
       "\" style=\"fill:none;\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 62.478125 172.100561 \n",
       "L 313.578125 172.100561 \n",
       "L 313.578125 9.020561 \n",
       "L 62.478125 9.020561 \n",
       "z\n",
       "\" style=\"fill:#ffffff;\"/>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path clip-path=\"url(#pc0e205ba3f)\" d=\"M 224.771827 172.100561 \n",
       "L 224.771827 9.020561 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" id=\"m838c2163f4\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"224.771827\" xlink:href=\"#m838c2163f4\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- $\\mathdefault{10^{2}}$ -->\n",
       "      <g transform=\"translate(215.971827 186.698998)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 12.40625 8.296875 \n",
       "L 28.515625 8.296875 \n",
       "L 28.515625 63.921875 \n",
       "L 10.984375 60.40625 \n",
       "L 10.984375 69.390625 \n",
       "L 28.421875 72.90625 \n",
       "L 38.28125 72.90625 \n",
       "L 38.28125 8.296875 \n",
       "L 54.390625 8.296875 \n",
       "L 54.390625 0 \n",
       "L 12.40625 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-49\"/>\n",
       "        <path d=\"M 31.78125 66.40625 \n",
       "Q 24.171875 66.40625 20.328125 58.90625 \n",
       "Q 16.5 51.421875 16.5 36.375 \n",
       "Q 16.5 21.390625 20.328125 13.890625 \n",
       "Q 24.171875 6.390625 31.78125 6.390625 \n",
       "Q 39.453125 6.390625 43.28125 13.890625 \n",
       "Q 47.125 21.390625 47.125 36.375 \n",
       "Q 47.125 51.421875 43.28125 58.90625 \n",
       "Q 39.453125 66.40625 31.78125 66.40625 \n",
       "z\n",
       "M 31.78125 74.21875 \n",
       "Q 44.046875 74.21875 50.515625 64.515625 \n",
       "Q 56.984375 54.828125 56.984375 36.375 \n",
       "Q 56.984375 17.96875 50.515625 8.265625 \n",
       "Q 44.046875 -1.421875 31.78125 -1.421875 \n",
       "Q 19.53125 -1.421875 13.0625 8.265625 \n",
       "Q 6.59375 17.96875 6.59375 36.375 \n",
       "Q 6.59375 54.828125 13.0625 64.515625 \n",
       "Q 19.53125 74.21875 31.78125 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-48\"/>\n",
       "        <path d=\"M 19.1875 8.296875 \n",
       "L 53.609375 8.296875 \n",
       "L 53.609375 0 \n",
       "L 7.328125 0 \n",
       "L 7.328125 8.296875 \n",
       "Q 12.9375 14.109375 22.625 23.890625 \n",
       "Q 32.328125 33.6875 34.8125 36.53125 \n",
       "Q 39.546875 41.84375 41.421875 45.53125 \n",
       "Q 43.3125 49.21875 43.3125 52.78125 \n",
       "Q 43.3125 58.59375 39.234375 62.25 \n",
       "Q 35.15625 65.921875 28.609375 65.921875 \n",
       "Q 23.96875 65.921875 18.8125 64.3125 \n",
       "Q 13.671875 62.703125 7.8125 59.421875 \n",
       "L 7.8125 69.390625 \n",
       "Q 13.765625 71.78125 18.9375 73 \n",
       "Q 24.125 74.21875 28.421875 74.21875 \n",
       "Q 39.75 74.21875 46.484375 68.546875 \n",
       "Q 53.21875 62.890625 53.21875 53.421875 \n",
       "Q 53.21875 48.921875 51.53125 44.890625 \n",
       "Q 49.859375 40.875 45.40625 35.40625 \n",
       "Q 44.1875 33.984375 37.640625 27.21875 \n",
       "Q 31.109375 20.453125 19.1875 8.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-50\"/>\n",
       "       </defs>\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use transform=\"translate(63.623047 0.765625)\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use transform=\"translate(128.203125 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L 0 2 \n",
       "\" id=\"m0bd4723779\" style=\"stroke:#000000;stroke-width:0.6;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"92.263612\" xlink:href=\"#m0bd4723779\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"125.646359\" xlink:href=\"#m0bd4723779\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_4\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"149.331794\" xlink:href=\"#m0bd4723779\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_5\">\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"167.703645\" xlink:href=\"#m0bd4723779\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_6\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"182.714541\" xlink:href=\"#m0bd4723779\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_7\">\n",
       "     <g id=\"line2d_8\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"195.406072\" xlink:href=\"#m0bd4723779\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_8\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"206.399976\" xlink:href=\"#m0bd4723779\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_9\">\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"216.097287\" xlink:href=\"#m0bd4723779\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_10\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"281.840009\" xlink:href=\"#m0bd4723779\" y=\"172.100561\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_2\">\n",
       "     <!-- Size -->\n",
       "     <g transform=\"translate(177.764062 200.377123)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path d=\"M 53.515625 70.515625 \n",
       "L 53.515625 60.890625 \n",
       "Q 47.90625 63.578125 42.921875 64.890625 \n",
       "Q 37.9375 66.21875 33.296875 66.21875 \n",
       "Q 25.25 66.21875 20.875 63.09375 \n",
       "Q 16.5 59.96875 16.5 54.203125 \n",
       "Q 16.5 49.359375 19.40625 46.890625 \n",
       "Q 22.3125 44.4375 30.421875 42.921875 \n",
       "L 36.375 41.703125 \n",
       "Q 47.40625 39.59375 52.65625 34.296875 \n",
       "Q 57.90625 29 57.90625 20.125 \n",
       "Q 57.90625 9.515625 50.796875 4.046875 \n",
       "Q 43.703125 -1.421875 29.984375 -1.421875 \n",
       "Q 24.8125 -1.421875 18.96875 -0.25 \n",
       "Q 13.140625 0.921875 6.890625 3.21875 \n",
       "L 6.890625 13.375 \n",
       "Q 12.890625 10.015625 18.65625 8.296875 \n",
       "Q 24.421875 6.59375 29.984375 6.59375 \n",
       "Q 38.421875 6.59375 43.015625 9.90625 \n",
       "Q 47.609375 13.234375 47.609375 19.390625 \n",
       "Q 47.609375 24.75 44.3125 27.78125 \n",
       "Q 41.015625 30.8125 33.5 32.328125 \n",
       "L 27.484375 33.5 \n",
       "Q 16.453125 35.6875 11.515625 40.375 \n",
       "Q 6.59375 45.0625 6.59375 53.421875 \n",
       "Q 6.59375 63.09375 13.40625 68.65625 \n",
       "Q 20.21875 74.21875 32.171875 74.21875 \n",
       "Q 37.3125 74.21875 42.625 73.28125 \n",
       "Q 47.953125 72.359375 53.515625 70.515625 \n",
       "z\n",
       "\" id=\"DejaVuSans-83\"/>\n",
       "       <path d=\"M 9.421875 54.6875 \n",
       "L 18.40625 54.6875 \n",
       "L 18.40625 0 \n",
       "L 9.421875 0 \n",
       "z\n",
       "M 9.421875 75.984375 \n",
       "L 18.40625 75.984375 \n",
       "L 18.40625 64.59375 \n",
       "L 9.421875 64.59375 \n",
       "z\n",
       "\" id=\"DejaVuSans-105\"/>\n",
       "       <path d=\"M 5.515625 54.6875 \n",
       "L 48.1875 54.6875 \n",
       "L 48.1875 46.484375 \n",
       "L 14.40625 7.171875 \n",
       "L 48.1875 7.171875 \n",
       "L 48.1875 0 \n",
       "L 4.296875 0 \n",
       "L 4.296875 8.203125 \n",
       "L 38.09375 47.515625 \n",
       "L 5.515625 47.515625 \n",
       "z\n",
       "\" id=\"DejaVuSans-122\"/>\n",
       "       <path d=\"M 56.203125 29.59375 \n",
       "L 56.203125 25.203125 \n",
       "L 14.890625 25.203125 \n",
       "Q 15.484375 15.921875 20.484375 11.0625 \n",
       "Q 25.484375 6.203125 34.421875 6.203125 \n",
       "Q 39.59375 6.203125 44.453125 7.46875 \n",
       "Q 49.3125 8.734375 54.109375 11.28125 \n",
       "L 54.109375 2.78125 \n",
       "Q 49.265625 0.734375 44.1875 -0.34375 \n",
       "Q 39.109375 -1.421875 33.890625 -1.421875 \n",
       "Q 20.796875 -1.421875 13.15625 6.1875 \n",
       "Q 5.515625 13.8125 5.515625 26.8125 \n",
       "Q 5.515625 40.234375 12.765625 48.109375 \n",
       "Q 20.015625 56 32.328125 56 \n",
       "Q 43.359375 56 49.78125 48.890625 \n",
       "Q 56.203125 41.796875 56.203125 29.59375 \n",
       "z\n",
       "M 47.21875 32.234375 \n",
       "Q 47.125 39.59375 43.09375 43.984375 \n",
       "Q 39.0625 48.390625 32.421875 48.390625 \n",
       "Q 24.90625 48.390625 20.390625 44.140625 \n",
       "Q 15.875 39.890625 15.1875 32.171875 \n",
       "z\n",
       "\" id=\"DejaVuSans-101\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-83\"/>\n",
       "      <use x=\"63.476562\" xlink:href=\"#DejaVuSans-105\"/>\n",
       "      <use x=\"91.259766\" xlink:href=\"#DejaVuSans-122\"/>\n",
       "      <use x=\"143.75\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_12\">\n",
       "      <path clip-path=\"url(#pc0e205ba3f)\" d=\"M 62.478125 142.53915 \n",
       "L 313.578125 142.53915 \n",
       "\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_13\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" id=\"m7d1f30c882\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"62.478125\" xlink:href=\"#m7d1f30c882\" y=\"142.53915\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- $\\mathdefault{10^{2}}$ -->\n",
       "      <g transform=\"translate(37.878125 146.338368)scale(0.1 -0.1)\">\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use transform=\"translate(63.623047 0.765625)\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use transform=\"translate(128.203125 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_14\">\n",
       "      <defs>\n",
       "       <path d=\"M 0 0 \n",
       "L -2 0 \n",
       "\" id=\"me39b0ca24f\" style=\"stroke:#000000;stroke-width:0.6;\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#me39b0ca24f\" y=\"168.724025\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#me39b0ca24f\" y=\"158.920973\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_16\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#me39b0ca24f\" y=\"150.274069\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_17\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#me39b0ca24f\" y=\"91.652558\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_4\">\n",
       "      <!-- $\\mathdefault{2\\times10^{2}}$ -->\n",
       "      <g transform=\"translate(20.878125 95.451777)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 70.125 53.71875 \n",
       "L 47.796875 31.296875 \n",
       "L 70.125 8.984375 \n",
       "L 64.3125 3.078125 \n",
       "L 41.890625 25.484375 \n",
       "L 19.484375 3.078125 \n",
       "L 13.71875 8.984375 \n",
       "L 35.984375 31.296875 \n",
       "L 13.71875 53.71875 \n",
       "L 19.484375 59.625 \n",
       "L 41.890625 37.203125 \n",
       "L 64.3125 59.625 \n",
       "z\n",
       "\" id=\"DejaVuSans-215\"/>\n",
       "       </defs>\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "       <use transform=\"translate(83.105469 0.765625)\" xlink:href=\"#DejaVuSans-215\"/>\n",
       "       <use transform=\"translate(186.376953 0.765625)\" xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use transform=\"translate(250 0.765625)\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use transform=\"translate(314.580078 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_6\">\n",
       "     <g id=\"line2d_18\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#me39b0ca24f\" y=\"61.88581\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- $\\mathdefault{3\\times10^{2}}$ -->\n",
       "      <g transform=\"translate(20.878125 65.685029)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 40.578125 39.3125 \n",
       "Q 47.65625 37.796875 51.625 33 \n",
       "Q 55.609375 28.21875 55.609375 21.1875 \n",
       "Q 55.609375 10.40625 48.1875 4.484375 \n",
       "Q 40.765625 -1.421875 27.09375 -1.421875 \n",
       "Q 22.515625 -1.421875 17.65625 -0.515625 \n",
       "Q 12.796875 0.390625 7.625 2.203125 \n",
       "L 7.625 11.71875 \n",
       "Q 11.71875 9.328125 16.59375 8.109375 \n",
       "Q 21.484375 6.890625 26.8125 6.890625 \n",
       "Q 36.078125 6.890625 40.9375 10.546875 \n",
       "Q 45.796875 14.203125 45.796875 21.1875 \n",
       "Q 45.796875 27.640625 41.28125 31.265625 \n",
       "Q 36.765625 34.90625 28.71875 34.90625 \n",
       "L 20.21875 34.90625 \n",
       "L 20.21875 43.015625 \n",
       "L 29.109375 43.015625 \n",
       "Q 36.375 43.015625 40.234375 45.921875 \n",
       "Q 44.09375 48.828125 44.09375 54.296875 \n",
       "Q 44.09375 59.90625 40.109375 62.90625 \n",
       "Q 36.140625 65.921875 28.71875 65.921875 \n",
       "Q 24.65625 65.921875 20.015625 65.03125 \n",
       "Q 15.375 64.15625 9.8125 62.3125 \n",
       "L 9.8125 71.09375 \n",
       "Q 15.4375 72.65625 20.34375 73.4375 \n",
       "Q 25.25 74.21875 29.59375 74.21875 \n",
       "Q 40.828125 74.21875 47.359375 69.109375 \n",
       "Q 53.90625 64.015625 53.90625 55.328125 \n",
       "Q 53.90625 49.265625 50.4375 45.09375 \n",
       "Q 46.96875 40.921875 40.578125 39.3125 \n",
       "z\n",
       "\" id=\"DejaVuSans-51\"/>\n",
       "       </defs>\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-51\"/>\n",
       "       <use transform=\"translate(83.105469 0.765625)\" xlink:href=\"#DejaVuSans-215\"/>\n",
       "       <use transform=\"translate(186.376953 0.765625)\" xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use transform=\"translate(250 0.765625)\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use transform=\"translate(314.580078 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_7\">\n",
       "     <g id=\"line2d_19\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#me39b0ca24f\" y=\"40.765967\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- $\\mathdefault{4\\times10^{2}}$ -->\n",
       "      <g transform=\"translate(20.878125 44.565185)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 37.796875 64.3125 \n",
       "L 12.890625 25.390625 \n",
       "L 37.796875 25.390625 \n",
       "z\n",
       "M 35.203125 72.90625 \n",
       "L 47.609375 72.90625 \n",
       "L 47.609375 25.390625 \n",
       "L 58.015625 25.390625 \n",
       "L 58.015625 17.1875 \n",
       "L 47.609375 17.1875 \n",
       "L 47.609375 0 \n",
       "L 37.796875 0 \n",
       "L 37.796875 17.1875 \n",
       "L 4.890625 17.1875 \n",
       "L 4.890625 26.703125 \n",
       "z\n",
       "\" id=\"DejaVuSans-52\"/>\n",
       "       </defs>\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-52\"/>\n",
       "       <use transform=\"translate(83.105469 0.765625)\" xlink:href=\"#DejaVuSans-215\"/>\n",
       "       <use transform=\"translate(186.376953 0.765625)\" xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use transform=\"translate(250 0.765625)\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use transform=\"translate(314.580078 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_8\">\n",
       "     <g id=\"line2d_20\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#me39b0ca24f\" y=\"24.384143\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_9\">\n",
       "     <g id=\"line2d_21\">\n",
       "      <g>\n",
       "       <use style=\"stroke:#000000;stroke-width:0.6;\" x=\"62.478125\" xlink:href=\"#me39b0ca24f\" y=\"10.999219\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- $\\mathdefault{6\\times10^{2}}$ -->\n",
       "      <g transform=\"translate(20.878125 14.798437)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path d=\"M 33.015625 40.375 \n",
       "Q 26.375 40.375 22.484375 35.828125 \n",
       "Q 18.609375 31.296875 18.609375 23.390625 \n",
       "Q 18.609375 15.53125 22.484375 10.953125 \n",
       "Q 26.375 6.390625 33.015625 6.390625 \n",
       "Q 39.65625 6.390625 43.53125 10.953125 \n",
       "Q 47.40625 15.53125 47.40625 23.390625 \n",
       "Q 47.40625 31.296875 43.53125 35.828125 \n",
       "Q 39.65625 40.375 33.015625 40.375 \n",
       "z\n",
       "M 52.59375 71.296875 \n",
       "L 52.59375 62.3125 \n",
       "Q 48.875 64.0625 45.09375 64.984375 \n",
       "Q 41.3125 65.921875 37.59375 65.921875 \n",
       "Q 27.828125 65.921875 22.671875 59.328125 \n",
       "Q 17.53125 52.734375 16.796875 39.40625 \n",
       "Q 19.671875 43.65625 24.015625 45.921875 \n",
       "Q 28.375 48.1875 33.59375 48.1875 \n",
       "Q 44.578125 48.1875 50.953125 41.515625 \n",
       "Q 57.328125 34.859375 57.328125 23.390625 \n",
       "Q 57.328125 12.15625 50.6875 5.359375 \n",
       "Q 44.046875 -1.421875 33.015625 -1.421875 \n",
       "Q 20.359375 -1.421875 13.671875 8.265625 \n",
       "Q 6.984375 17.96875 6.984375 36.375 \n",
       "Q 6.984375 53.65625 15.1875 63.9375 \n",
       "Q 23.390625 74.21875 37.203125 74.21875 \n",
       "Q 40.921875 74.21875 44.703125 73.484375 \n",
       "Q 48.484375 72.75 52.59375 71.296875 \n",
       "z\n",
       "\" id=\"DejaVuSans-54\"/>\n",
       "       </defs>\n",
       "       <use transform=\"translate(0 0.765625)\" xlink:href=\"#DejaVuSans-54\"/>\n",
       "       <use transform=\"translate(83.105469 0.765625)\" xlink:href=\"#DejaVuSans-215\"/>\n",
       "       <use transform=\"translate(186.376953 0.765625)\" xlink:href=\"#DejaVuSans-49\"/>\n",
       "       <use transform=\"translate(250 0.765625)\" xlink:href=\"#DejaVuSans-48\"/>\n",
       "       <use transform=\"translate(314.580078 39.046875)scale(0.7)\" xlink:href=\"#DejaVuSans-50\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_8\">\n",
       "     <!-- GFLOPS -->\n",
       "     <g transform=\"translate(14.798438 110.040248)rotate(-90)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path d=\"M 59.515625 10.40625 \n",
       "L 59.515625 29.984375 \n",
       "L 43.40625 29.984375 \n",
       "L 43.40625 38.09375 \n",
       "L 69.28125 38.09375 \n",
       "L 69.28125 6.78125 \n",
       "Q 63.578125 2.734375 56.6875 0.65625 \n",
       "Q 49.8125 -1.421875 42 -1.421875 \n",
       "Q 24.90625 -1.421875 15.25 8.5625 \n",
       "Q 5.609375 18.5625 5.609375 36.375 \n",
       "Q 5.609375 54.25 15.25 64.234375 \n",
       "Q 24.90625 74.21875 42 74.21875 \n",
       "Q 49.125 74.21875 55.546875 72.453125 \n",
       "Q 61.96875 70.703125 67.390625 67.28125 \n",
       "L 67.390625 56.78125 \n",
       "Q 61.921875 61.421875 55.765625 63.765625 \n",
       "Q 49.609375 66.109375 42.828125 66.109375 \n",
       "Q 29.4375 66.109375 22.71875 58.640625 \n",
       "Q 16.015625 51.171875 16.015625 36.375 \n",
       "Q 16.015625 21.625 22.71875 14.15625 \n",
       "Q 29.4375 6.6875 42.828125 6.6875 \n",
       "Q 48.046875 6.6875 52.140625 7.59375 \n",
       "Q 56.25 8.5 59.515625 10.40625 \n",
       "z\n",
       "\" id=\"DejaVuSans-71\"/>\n",
       "       <path d=\"M 9.8125 72.90625 \n",
       "L 51.703125 72.90625 \n",
       "L 51.703125 64.59375 \n",
       "L 19.671875 64.59375 \n",
       "L 19.671875 43.109375 \n",
       "L 48.578125 43.109375 \n",
       "L 48.578125 34.8125 \n",
       "L 19.671875 34.8125 \n",
       "L 19.671875 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-70\"/>\n",
       "       <path d=\"M 9.8125 72.90625 \n",
       "L 19.671875 72.90625 \n",
       "L 19.671875 8.296875 \n",
       "L 55.171875 8.296875 \n",
       "L 55.171875 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-76\"/>\n",
       "       <path d=\"M 39.40625 66.21875 \n",
       "Q 28.65625 66.21875 22.328125 58.203125 \n",
       "Q 16.015625 50.203125 16.015625 36.375 \n",
       "Q 16.015625 22.609375 22.328125 14.59375 \n",
       "Q 28.65625 6.59375 39.40625 6.59375 \n",
       "Q 50.140625 6.59375 56.421875 14.59375 \n",
       "Q 62.703125 22.609375 62.703125 36.375 \n",
       "Q 62.703125 50.203125 56.421875 58.203125 \n",
       "Q 50.140625 66.21875 39.40625 66.21875 \n",
       "z\n",
       "M 39.40625 74.21875 \n",
       "Q 54.734375 74.21875 63.90625 63.9375 \n",
       "Q 73.09375 53.65625 73.09375 36.375 \n",
       "Q 73.09375 19.140625 63.90625 8.859375 \n",
       "Q 54.734375 -1.421875 39.40625 -1.421875 \n",
       "Q 24.03125 -1.421875 14.8125 8.828125 \n",
       "Q 5.609375 19.09375 5.609375 36.375 \n",
       "Q 5.609375 53.65625 14.8125 63.9375 \n",
       "Q 24.03125 74.21875 39.40625 74.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-79\"/>\n",
       "       <path d=\"M 19.671875 64.796875 \n",
       "L 19.671875 37.40625 \n",
       "L 32.078125 37.40625 \n",
       "Q 38.96875 37.40625 42.71875 40.96875 \n",
       "Q 46.484375 44.53125 46.484375 51.125 \n",
       "Q 46.484375 57.671875 42.71875 61.234375 \n",
       "Q 38.96875 64.796875 32.078125 64.796875 \n",
       "z\n",
       "M 9.8125 72.90625 \n",
       "L 32.078125 72.90625 \n",
       "Q 44.34375 72.90625 50.609375 67.359375 \n",
       "Q 56.890625 61.8125 56.890625 51.125 \n",
       "Q 56.890625 40.328125 50.609375 34.8125 \n",
       "Q 44.34375 29.296875 32.078125 29.296875 \n",
       "L 19.671875 29.296875 \n",
       "L 19.671875 0 \n",
       "L 9.8125 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-80\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-71\"/>\n",
       "      <use x=\"77.490234\" xlink:href=\"#DejaVuSans-70\"/>\n",
       "      <use x=\"135.009766\" xlink:href=\"#DejaVuSans-76\"/>\n",
       "      <use x=\"187.097656\" xlink:href=\"#DejaVuSans-79\"/>\n",
       "      <use x=\"265.808594\" xlink:href=\"#DejaVuSans-80\"/>\n",
       "      <use x=\"326.111328\" xlink:href=\"#DejaVuSans-83\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_22\">\n",
       "    <path clip-path=\"url(#pc0e205ba3f)\" d=\"M 73.891761 164.687834 \n",
       "L 130.959943 97.343343 \n",
       "L 188.028125 51.990049 \n",
       "L 245.096307 32.350472 \n",
       "L 302.164489 16.433288 \n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-dasharray:5.55,2.4;stroke-dashoffset:0;stroke-width:1.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_23\">\n",
       "    <path clip-path=\"url(#pc0e205ba3f)\" d=\"M 73.891761 93.919544 \n",
       "L 130.959943 52.735815 \n",
       "L 188.028125 31.680099 \n",
       "L 245.096307 19.701844 \n",
       "L 302.164489 16.855341 \n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 62.478125 172.100561 \n",
       "L 62.478125 9.020561 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 313.578125 172.100561 \n",
       "L 313.578125 9.020561 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 62.478125 172.100561 \n",
       "L 313.578125 172.100561 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 62.478125 9.020561 \n",
       "L 313.578125 9.020561 \n",
       "\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n",
       "   </g>\n",
       "   <g id=\"legend_1\">\n",
       "    <g id=\"patch_7\">\n",
       "     <path d=\"M 69.478125 46.376811 \n",
       "L 133.548438 46.376811 \n",
       "Q 135.548438 46.376811 135.548438 44.376811 \n",
       "L 135.548438 16.020561 \n",
       "Q 135.548438 14.020561 133.548438 14.020561 \n",
       "L 69.478125 14.020561 \n",
       "Q 67.478125 14.020561 67.478125 16.020561 \n",
       "L 67.478125 44.376811 \n",
       "Q 67.478125 46.376811 69.478125 46.376811 \n",
       "z\n",
       "\" style=\"fill:#ffffff;opacity:0.8;stroke:#cccccc;stroke-linejoin:miter;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_24\">\n",
       "     <path d=\"M 71.478125 22.118998 \n",
       "L 91.478125 22.118998 \n",
       "\" style=\"fill:none;stroke:#1f77b4;stroke-dasharray:5.55,2.4;stroke-dashoffset:0;stroke-width:1.5;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_25\"/>\n",
       "    <g id=\"text_9\">\n",
       "     <!-- mxnet -->\n",
       "     <g transform=\"translate(99.478125 25.618998)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path d=\"M 52 44.1875 \n",
       "Q 55.375 50.25 60.0625 53.125 \n",
       "Q 64.75 56 71.09375 56 \n",
       "Q 79.640625 56 84.28125 50.015625 \n",
       "Q 88.921875 44.046875 88.921875 33.015625 \n",
       "L 88.921875 0 \n",
       "L 79.890625 0 \n",
       "L 79.890625 32.71875 \n",
       "Q 79.890625 40.578125 77.09375 44.375 \n",
       "Q 74.3125 48.1875 68.609375 48.1875 \n",
       "Q 61.625 48.1875 57.5625 43.546875 \n",
       "Q 53.515625 38.921875 53.515625 30.90625 \n",
       "L 53.515625 0 \n",
       "L 44.484375 0 \n",
       "L 44.484375 32.71875 \n",
       "Q 44.484375 40.625 41.703125 44.40625 \n",
       "Q 38.921875 48.1875 33.109375 48.1875 \n",
       "Q 26.21875 48.1875 22.15625 43.53125 \n",
       "Q 18.109375 38.875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.1875 51.21875 25.484375 53.609375 \n",
       "Q 29.78125 56 35.6875 56 \n",
       "Q 41.65625 56 45.828125 52.96875 \n",
       "Q 50 49.953125 52 44.1875 \n",
       "z\n",
       "\" id=\"DejaVuSans-109\"/>\n",
       "       <path d=\"M 54.890625 54.6875 \n",
       "L 35.109375 28.078125 \n",
       "L 55.90625 0 \n",
       "L 45.3125 0 \n",
       "L 29.390625 21.484375 \n",
       "L 13.484375 0 \n",
       "L 2.875 0 \n",
       "L 24.125 28.609375 \n",
       "L 4.6875 54.6875 \n",
       "L 15.28125 54.6875 \n",
       "L 29.78125 35.203125 \n",
       "L 44.28125 54.6875 \n",
       "z\n",
       "\" id=\"DejaVuSans-120\"/>\n",
       "       <path d=\"M 54.890625 33.015625 \n",
       "L 54.890625 0 \n",
       "L 45.90625 0 \n",
       "L 45.90625 32.71875 \n",
       "Q 45.90625 40.484375 42.875 44.328125 \n",
       "Q 39.84375 48.1875 33.796875 48.1875 \n",
       "Q 26.515625 48.1875 22.3125 43.546875 \n",
       "Q 18.109375 38.921875 18.109375 30.90625 \n",
       "L 18.109375 0 \n",
       "L 9.078125 0 \n",
       "L 9.078125 54.6875 \n",
       "L 18.109375 54.6875 \n",
       "L 18.109375 46.1875 \n",
       "Q 21.34375 51.125 25.703125 53.5625 \n",
       "Q 30.078125 56 35.796875 56 \n",
       "Q 45.21875 56 50.046875 50.171875 \n",
       "Q 54.890625 44.34375 54.890625 33.015625 \n",
       "z\n",
       "\" id=\"DejaVuSans-110\"/>\n",
       "       <path d=\"M 18.3125 70.21875 \n",
       "L 18.3125 54.6875 \n",
       "L 36.8125 54.6875 \n",
       "L 36.8125 47.703125 \n",
       "L 18.3125 47.703125 \n",
       "L 18.3125 18.015625 \n",
       "Q 18.3125 11.328125 20.140625 9.421875 \n",
       "Q 21.96875 7.515625 27.59375 7.515625 \n",
       "L 36.8125 7.515625 \n",
       "L 36.8125 0 \n",
       "L 27.59375 0 \n",
       "Q 17.1875 0 13.234375 3.875 \n",
       "Q 9.28125 7.765625 9.28125 18.015625 \n",
       "L 9.28125 47.703125 \n",
       "L 2.6875 47.703125 \n",
       "L 2.6875 54.6875 \n",
       "L 9.28125 54.6875 \n",
       "L 9.28125 70.21875 \n",
       "z\n",
       "\" id=\"DejaVuSans-116\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-109\"/>\n",
       "      <use x=\"97.412109\" xlink:href=\"#DejaVuSans-120\"/>\n",
       "      <use x=\"156.591797\" xlink:href=\"#DejaVuSans-110\"/>\n",
       "      <use x=\"219.970703\" xlink:href=\"#DejaVuSans-101\"/>\n",
       "      <use x=\"281.494141\" xlink:href=\"#DejaVuSans-116\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"line2d_26\">\n",
       "     <path d=\"M 71.478125 36.797123 \n",
       "L 91.478125 36.797123 \n",
       "\" style=\"fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:1.5;\"/>\n",
       "    </g>\n",
       "    <g id=\"line2d_27\"/>\n",
       "    <g id=\"text_10\">\n",
       "     <!-- tvm -->\n",
       "     <g transform=\"translate(99.478125 40.297123)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path d=\"M 2.984375 54.6875 \n",
       "L 12.5 54.6875 \n",
       "L 29.59375 8.796875 \n",
       "L 46.6875 54.6875 \n",
       "L 56.203125 54.6875 \n",
       "L 35.6875 0 \n",
       "L 23.484375 0 \n",
       "z\n",
       "\" id=\"DejaVuSans-118\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-116\"/>\n",
       "      <use x=\"39.208984\" xlink:href=\"#DejaVuSans-118\"/>\n",
       "      <use x=\"98.388672\" xlink:href=\"#DejaVuSans-109\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pc0e205ba3f\">\n",
       "   <rect height=\"163.08\" width=\"251.1\" x=\"62.478125\" y=\"9.020561\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 324x216 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "channels = 2**np.arange(4, 9)\n",
    "sizes = [(int(c), 64, 3) for c in channels] # a list of (c, n, k)\n",
    "tvm_gflops = d2ltvm.bench_conv_tvm(cached_block, sizes, target)\n",
    "mxnet_gflops = d2ltvm.bench_conv_mxnet(sizes)\n",
    "d2ltvm.plot_gflops(channels, [mxnet_gflops, tvm_gflops], ['mxnet', 'tvm'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 18
   },
   "source": [
    "## Summary\n",
    "\n",
    "- We often tile input and output channels to for better cache efficiency and pack data accordingly.\n",
    "\n",
    "## Exercises\n",
    "\n",
    "- What if the number of channels cannot be divided by the tiling size?\n",
    "- Try different tiling sizes.\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}